function do_hook() {

    var rand16Str = Module.findExportByName("libkeyinfo.so", "rand16Str");
    console.log('rand16Str addr = ', rand16Str);
    if (rand16Str) {
        Interceptor.attach(rand16Str, {
            onEnter: function (args) {
                this.x1 = args[0]
            },
            onLeave: function (retval) {
                // console.log('5.rand16Str 返回值：', hexdump(this.x1), "\n");
                console.log('5.rand16Str=iv 返回值：', hexdump(this.x1, {length: 16}), "\n");

            }
        });
    }

}

function delay_hook(so_name, hook_func) {
    var dlopen = Module.findExportByName(null, "dlopen");
    var android_dlopen_ext = Module.findExportByName(null, "android_dlopen_ext");

    Interceptor.attach(dlopen, {
        onEnter: function (args) {
            var path_ptr = args[0];
            var path = ptr(path_ptr).readCString();
            // console.log("[dlopen:]", path);
            this.path = path;
        }, onLeave: function (retval) {
            if (this.path.indexOf(so_name) !== -1) {
                console.log("[dlopen:]", this.path);
                hook_func();

            }
        }
    });

    Interceptor.attach(android_dlopen_ext, {
        onEnter: function (args) {
            var path_ptr = args[0];
            var path = ptr(path_ptr).readCString();
            this.path = path;
        },
        onLeave: function (retval) {
            if (this.path.indexOf(so_name) !== -1) {
                console.log("\nandroid_dlopen_ext加载：", this.path);
                hook_func();
            }
        }
    });
}

delay_hook("libkeyinfo.so", do_hook);


// frida -H 127.0.0.1:8877 -l  15_hook_so_iv.js -f com.achievo.vipshop